package org.scirp.ijmis.service.personpaper.impl;

import java.util.List;

import org.scirp.ijmis.dao.personpaper.IResearchFieldOfPaperDAO;
import org.scirp.ijmis.po.personpaper.ResearchFieldOfPaper;
import org.scirp.ijmis.po.personpaper.ResearchFieldOfPerson;
import org.scirp.ijmis.service.personpaper.IResearchFieldOfPaperService;

public class ResearchFieldOfPaperServiceImpl implements IResearchFieldOfPaperService {
	private IResearchFieldOfPaperDAO researchFieldOfPaperDAO;
	@Override
	public boolean deleteResearchFieldOfPaper(ResearchFieldOfPaper researchFieldOfPaper) {
		return researchFieldOfPaperDAO.deleteResearchFieldOfPaper(researchFieldOfPaper);
	}

	@Override
	public boolean deleteResearchFieldOfPaperByPaperId(Long paperId) {
		return researchFieldOfPaperDAO.deleteResearchFieldOfPaperByPaperId(paperId);
	}

	@Override
	public boolean saveResearchFieldOfPaper(ResearchFieldOfPaper researchFieldOfPaper) {
		return researchFieldOfPaperDAO.saveResearchFieldOfPaper(researchFieldOfPaper);
	}

	@Override
	public List<ResearchFieldOfPaper> selectAll() {
		return researchFieldOfPaperDAO.selectAll();
	}

	@Override
	public ResearchFieldOfPaper selectById(long id) {
		return researchFieldOfPaperDAO.selectById(id);
	}

	@Override
	public List<ResearchFieldOfPaper> selectByPaperId(long paperId) {
		return researchFieldOfPaperDAO.selectByPaperId(paperId);
	}

	@Override
	public boolean updateResearchFieldOfPaper(ResearchFieldOfPaper researchFieldOfPaper) {
		return researchFieldOfPaperDAO.updateResearchFieldOfPaper(researchFieldOfPaper);
	}
	public boolean updatePaperResearchField(Long paperId,List<ResearchFieldOfPaper> researchFieldOfPaperList)
	{
		boolean flag=researchFieldOfPaperDAO.deleteResearchFieldOfPaperByPaperId(paperId);
		if(flag){
			boolean fla=true;
			for(ResearchFieldOfPaper researchFieldOfPaper:researchFieldOfPaperList){
				if(!researchFieldOfPaperDAO.saveResearchFieldOfPaper(researchFieldOfPaper)){
					fla=false;
				}
			}
			return fla;
		}
		else{
			return false;
		}
		
	}
	
	
	
	
	
	
	
	
	public IResearchFieldOfPaperDAO getResearchFieldOfPaperDAO() {
		return researchFieldOfPaperDAO;
	}

	public void setResearchFieldOfPaperDAO(IResearchFieldOfPaperDAO researchFieldOfPaperDAO) {
		this.researchFieldOfPaperDAO = researchFieldOfPaperDAO;
	}

}
